﻿using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

namespace CoreModule.Converters
{
    /// <summary>
    /// 血氧状态 
    /// </summary>
    public class BloodOxygenStatusToColorConverter : IValueConverter
    {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Color myColor = (Color)ColorConverter.ConvertFromString("#11A84D");
            SolidColorBrush myBrush = new SolidColorBrush(myColor);
            if (value == null)
            {
                return myBrush;
            }

            BloodOxygenStatus status = (BloodOxygenStatus)value;

            switch (status)
            {
                case BloodOxygenStatus.None:
                    myColor = (Color)ColorConverter.ConvertFromString("#11A84D");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case BloodOxygenStatus.Low:
                    myColor = (Color)ColorConverter.ConvertFromString("#F58B00");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case BloodOxygenStatus.Normal:
                    myColor = (Color)ColorConverter.ConvertFromString("#11A84D");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                default:
                    return myBrush;
            }

        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}